/**
 * Copyright (c) 2018 软唐 All rights reserved.
 *
 * https://www.softtown.cn
 *
 * 版权所有，侵权必究！
 */

package com.softtown.modules.dapai.controller;

import com.github.pagehelper.PageInfo;
import com.softtown.common.utils.Result;
import com.softtown.modules.dapai.dto.CompVisitRecordDTO;
import com.softtown.modules.dapai.entity.CompVisitRecordEntity;
import com.softtown.modules.dapai.service.CompVisitRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
* @Author: Ding Ya Yong
* @Description: 拜访记录
* @date: 2022/1/2 20:47
* @Param:
* @return:
*/
@RestController
@RequestMapping("visitRecord")
@Api(tags="拜访记录")
public class CompVisitRecordController {

    @Resource
    private CompVisitRecordService compVisitRecordService;

    @PostMapping("getVisitRecordPageList")
    @ApiOperation("获取拜访记录分页")
    public Result getVisitRecordPageList(@RequestBody CompVisitRecordDTO compVisitRecordDTO) {
        PageInfo<CompVisitRecordDTO> compVisitRecordDTOPageInfo = compVisitRecordService.getVisitRecordPageList(compVisitRecordDTO);
        return new Result<PageInfo<CompVisitRecordDTO>>().ok(compVisitRecordDTOPageInfo);
    }



    @PostMapping("getVisitRecordById")
    @ApiOperation("获取拜访记录详情")
    public Result<CompVisitRecordEntity> getVisitRecordById(@RequestBody CompVisitRecordDTO compVisitRecordDTO) {
        CompVisitRecordEntity compVisitRecordEntity = compVisitRecordService.getVisitRecordById(compVisitRecordDTO.getCompId(),compVisitRecordDTO.getId());
        return new Result<CompVisitRecordEntity>().ok(compVisitRecordEntity);
    }


    @PostMapping("addVisitRecord")
    @ApiOperation("添加拜访记录")
    public Result addVisitRecord(@RequestBody CompVisitRecordDTO compVisitRecordDTO) {
        Result result = new Result<>();
        compVisitRecordService.addVisitRecord(compVisitRecordDTO);
        return result;
    }

    @PostMapping("updateVisitRecord")
    @ApiOperation("修改拜访记录")
    public Result updateVisitRecord(@RequestBody CompVisitRecordDTO compVisitRecordDTO) {
        Result result = new Result<>();
        compVisitRecordService.updateVisitRecord(compVisitRecordDTO);
        return result;
    }

    @PostMapping("deleteVisitRecord")
    @ApiOperation("删除拜访记录")
    public Result deleteVisitRecord(@RequestBody CompVisitRecordDTO compVisitRecordDTO) {
        Result result = new Result<>();
        compVisitRecordService.deleteVisitRecord(compVisitRecordDTO);
        return result;
    }

//    @PostMapping("listForVisitRecord")
//    @ApiOperation("拜访记录下拉框")
//    public Result listForVisitRecord(@RequestBody CompVisitRecordDTO compVisitRecordDTO) {
//        List<CompVisitRecordDTO> compVisitRecordDTOList = compVisitRecordService.listForVisitRecord(compVisitRecordDTO);
//        return new Result<List<CompVisitRecordDTO>>().ok(compVisitRecordDTOList);
//    }

}
